<template>
  <!-- 底部部分 => list有数据的时候，才展示  list.length > 0 -->
  <footer  class="footer" v-if="list.length > 0">
    <span class="todo-count"><strong>{{num &lt; 10 ? '0' + num : num}}</strong>剩余</span>
    <ul class="filters">
      <li>
        <a :class="{selected:status==='all'}" href="#/" @click="$emit('status-event','all')">全部</a>
      </li>
      <li>
        <a :class="{selected:status==='undone'}" href="#/active" @click="$emit('status-event','undone')">进行中</a>
      </li>
      <li>
        <a :class="{selected:status==='done'}" href="#/completed" @click="$emit('status-event','done')">已完成</a>
      </li>
    </ul>
    <!-- 有已完成的任务，才需要显示这个按钮 -->
    <button v-if="shouClear" @click="$emit('clear-all-event')" class="clear-completed">清除已完成</button>
  </footer>
</template>

<script>
export default {
  props: {
    list:{
      type:Array,
      required:true
    },
    status: {
      type:String,
      required:true
    }
  },
  computed: {
    num() {
      return this.list.filter(item => item.state === false).length
    },
    shouClear() {
      return this.list.some(item => item.state === true)
    }
  }
}
</script>

<style></style>
